package com.subframe7536.sa.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.subframe7536.sa.entity.LoginEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;

/**
 * <p>
 * 用户_登录信息 Mapper 接口
 * </p>
 *
 * @author subframe7536
 */
@Mapper
public interface LoginMapper extends BaseMapper<LoginEntity> {

    /**
     * 更新登录时间
     * @param phone id
     * @param datetime login date
     */
    @Update("UPDATE e_user a,e_user_login b\n" +
        "        set a.last_login=#{datetime}\n" +
        "        WHERE\n" +
        "            b.phone=#{phone}\n" +
        "          and\n" +
        "            b.user_id=a.user_id")
    void login(@Param("phone") String phone, @Param("datetime") LocalDateTime datetime);
}
